import 'package:fate_blind_box/im/searchmember.dart';
import 'package:fate_blind_box/utils/common_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../theme/theme_color.dart';
import '../ui/account/scan/scan_main_page.dart';
import '../widget/icon_text.dart';

class AddIndex extends StatefulWidget {
  Function? refreshBlock;

  AddIndex({Key? key, this.refreshBlock}) : super(key: key);

  @override
  State<AddIndex> createState() => _AddIndexState();
}

class _AddIndexState extends State<AddIndex>
    with SingleTickerProviderStateMixin {
  List _topAdvertes = [];
  final ScrollController _scrollController = ScrollController(); //listview的控制器
  int _page = 1; //加载的页数
  bool isLoading = false; //是否正在加载数据
  int _index = 0;

  // 创建Controller
  late TabController _tabController;

  @override
  void initState() {
    super.initState();

    _scrollController.addListener(() {
      if (_scrollController.position.pixels ==
          _scrollController.position.maxScrollExtent) {
        //_getMore();
      }
    });
  }

  _onTabChanged() {
    if (_tabController.index.toDouble() == _tabController.animation?.value) {
      //赋值 并更新数据
      _index = _tabController.index;
    }
  }

  @override
  Widget build(BuildContext context) {
    return AppWidget.navTitleBar(
      title: '添加',
      rightActions: [
        GestureDetector(
          onTap: () {
            Get.to(ScanMainPage(
              isAddGroup: true,
            ));
          },
          child: Container(
            padding: const EdgeInsets.only(right: 20),
            child: Image.asset(
              'images/scan/main_scan_white.png',
              width: 20,
              color: Colors.black,
            ),
          ),
        ),
      ],
      childWidget: Column(
        children: [
          // _buildSearchBar(),
          Expanded(
            flex: 1,
            child: SearchMember(
              refreshBlock: widget.refreshBlock,
            ),
          )
          // Expanded(child: _buildListView())
        ],
      ),
    );
  }

  Widget _buildSearchBar() {
    return GestureDetector(
      onTap: () {},
      child: Container(
          height: 32,
          margin: const EdgeInsets.symmetric(horizontal: 12),
          padding: const EdgeInsets.symmetric(horizontal: 24),
          decoration: ShapeDecoration(
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(16)),
              color: const Color(0xFFF7F7F7)),
          alignment: Alignment.centerLeft,
          child: IconText(
            "  搜索备注、昵称",
            style: TextStyle(color: ThemeColor.textColorSecond, fontSize: 13),
            icon: const Icon(
              Icons.search_rounded,
              size: 15,
              color: Color(0xFFBABABA),
            ),
            beforeText: true,
          )),
    );
  }
}
